package nc.impl.web.service;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import nc.bs.framework.common.NCLocator;
import nc.bs.jdbc.processor.ListMapProcessor;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.web.service.IWebService;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.vo.pub.BusinessException;

public class PoundBillPictureQueryImpl implements IWebService{
	
	private IUAPQueryBS iUAPQueryBS=null;

	public IUAPQueryBS getiUAPQueryBS(){
		if(iUAPQueryBS == null){
			return NCLocator.getInstance().lookup(IUAPQueryBS.class);
		}
		return iUAPQueryBS;
	}
	
	@Override
	public String processor(String json) throws BusinessException {
		
		Map<String,Object> jsonMap = (Map<String, Object>) JSONObject.parse(json);
		String sql = getQuerySQL(jsonMap);
		List<String> executeQuery = (List<String>) getiUAPQueryBS().executeQuery(sql, new ColumnListProcessor());
		return JSONArray.toJSON(executeQuery).toString();
	}

	private String getQuerySQL(Map<String, Object> jsonMap) throws BusinessException {
		StringBuffer sql = new StringBuffer();
		if(jsonMap != null){
			String pk_pound = jsonMap.get("pk_pound") == null ? "" : jsonMap.get("pk_pound").toString();
			sql.append("select url from bd_poundpictureurl where billid = '" + pk_pound + "'");
		}
		return sql.toString();
	}
}
